<!DOCTYPE html>
<html>
	<!--
		SiLL Version : {Development Version}
		File Revision : {Development Revision}

		SiLL
		Copyright (C) 2013 Matt Stypa

		This program is free software; you can redistribute it and/or
		modify it under the terms of the GNU General Public License
		as published by the Free Software Foundation; either version 2
		of the License, or (at your option) any later version.

		This program is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
		GNU General Public License for more details.

		You should have received a copy of the GNU General Public License
		along with this program; if not, write to the Free Software
		Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	-->
	
	<head>
		<title>SiLL Manual</title>
		<style>
			body{font-family:sans-serif;padding:0 2em;margin:0;font-size:1em;}
			a{color:#0645AD;text-decoration:none;}
			a:visited{color:#0B0080;}			
			a:hover{text-decoration:underline;}	
			h1{font-size:2em;font-weight:normal;border-bottom:1px solid #999;overflow:hidden;margin-top:1em;line-height:normal;}
			h2{font-size:1.6em;font-weight:normal;border-bottom:1px solid #999;overflow:hidden;margin-top:1.5em;line-height:normal;}
			h3{font-size:1.2em;margin-top:1.5em;line-height:normal;}
			h4{font-size:1em;font-weight:bold;border:none;margin:1em 0;line-height:normal;}
			p, .p{margin:1em 0;}
			ul{list-style-type:none;padding:0;margin:0 0 0 1em;}
			ul ul{padding:0 1.8em;}
			table tr td:not(:first-child){padding:0 0 0 1em;}
			.block{border:1px solid #999;background-color:#eee;padding:0 1em;margin:1em 0;}
			pre{font-family:consolas;display:inline-block;white-space:normal;margin:1em 0;border:none !important;padding:0;}
			span.code{font-family:consolas;white-space:nowrap;}
			.white{background-color:#fff;}
			.f-left{float:left;margin-right:2em;}
			.f-right{float:right;margin-left:2em;}
			.clear{clear:both;}
			.center{text-align:center;}
			.wide{width:30em;}
			.tall{height:20em;}
			.red{border:2px solid #f00;background-color:#edd;}
			@media print{body{font-size:0.5em;}}
		</style>
	</head>
	<body>
		<h1>SiLL</h1>
		<div class="block f-right">
			<div class="center p"><img src="sill_logo.png" title="SiLL"/></div>
			<table class="p">
				<tr>
					<td>Version:</td>
					<td>{Development Version}</td>
				</tr>
				<tr>
					<td>Developer:</td>
					<td>Matt Stypa</td>
				</tr>
				<tr>
					<td>Platform:</td>
					<td>PHP + MySQL</td>
				</tr>		
				<tr>
					<td>License:</td>
					<td><a href="http://www.gnu.org/licenses/gpl-2.0-standalone.html" title="GPL 2.0">GPL 2.0</a></td>
				</tr>		
				<tr>
					<td>Website</td>
					<td><a href="https://sill.codeplex.com/" title="sill.codeplex.com">sill.codeplex.com</a></td>
				</tr>	
			</table>
		</div>
		<p>
			<b>SiLL</b> is a PHP micro-framework that features a powerful router, PDO object access and module support. It offers unprecedented flexibility with no overhead present in other frameworks.
		</p>
		<div class="block f-left">
			<h4>Contents</h4>
			<div class="p">
				<ul>
					<li><a href="#section1" title="License">1. License</a></li>
					<li><a href="#section2" title="Requirements">2. Requirements</a></li>
					<li><a href="#section3" title="Installation">3. Installation</a></li>
					<li><a href="#section4" title="Configuration">4. Configuration</a>
						<ul>
							<li><a href="#section4.1" title="config.php">4.1. config.php</a></li>
							<li><a href="#section4.2" title=".htaccess">4.2. .htaccess</a></li>
						</ul>
					</li>
					<li><a href="#section5" title="Sill Function Reference">5. Sill Function Reference</a>
						<ul>
							<li><a href="#section5.1" title="global $sill">5.1. global $sill</a></li>
							<li><a href="#section5.2" title="$sill->load($file)">5.2. $sill->load($file)</a></li>
							<li><a href="#section5.3" title="$sill->route($route, $file)">5.3. $sill->route($route, $file)</a></li>
							<li><a href="#section5.4" title="$sill->module($module)">5.4. $sill->module($module)</a></li>
							<li><a href="#section5.5" title="$sill->URL($URL)">5.5. $sill->URL($URL)</a></li>
							<li><a href="#section5.6" title="$sill->arguments()">5.6. $sill->arguments()</a></li>
							<li><a href="#section5.7" title="$sill->v(&$v)">5.7. $sill->v(&$v)</a></li>
							<li><a href="#section5.8" title="$sill->PDO()">5.8. $sill->PDO()</a></li>
							<li><a href="#section5.9" title="$sill->version()">5.9. $sill->version()</a></li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		<div class="clear"></div>
		
		<h2 id="section1">License</h2>
			<p>
				<b>SiLL</b><br/>
				Copyright &reg; 2013 Matt Stypa<br/>
				<br/>
				This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.<br/>
				<br/>
				This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.<br/>
				<br/>
				You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
			</p>

		<h2 id="section2">Requirements</h2>
			<ul>
				<li>Apache 1.3 or newer (with mod_rewrite)</li>
				<li>PHP 5.1 or newer</li>
				<li>MySQL 4.1 or newer</li>
			</ul>
			
		<h2 id="section3">Installation</h2>
			<p>
				Copy <b>SiLL</b> files to the server. '<span class="code">Docs</span>' directory may be omitted.
			</p>
		
		<h2 id="section4">Configuration</h2>
			<h3 id="section4.1"><span class="code">config.php</span></h3>
				<p>
					In order for <b>SiLL</b> to function properly you will need to edit the configuration file.
				</p>
			<h3 id="section4.2"><span class="code">.htaccess</span></h3>
				<p>
					In most cases this file does not need to be edited but there are few exceptions. In the event <b>SiLL</b> is installed in a directory other than the base directory, the following line will need to be modified to represent the URL path where <b>SiLL</b> is accessible.
				</p>
				<div class="block">
					<pre>
						RewriteBase /
					</pre>
				</div>
				<div class="clear"></div>

		<h2 id="section5">Sill Function Reference</h2>
			<h3 id="section5.1"><span class="code">global $sill</span></h3>
				<p>
					Before any of the <b>SiLL</b> functions can be used, this global variable has to be declared.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							global $sill;
						</pre>
					</div>

				</div>
				<div class="clear"></div>
		
			<h3 id="section5.2"><span class="code">$sill-&gt;load($file)</span></h3>
				<p>
					Loads requested file from the '<span class="code">/site/</span>' directory if it exists.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$sill-&gt;load('header.php');
						</pre>
					</div>
					<p>
						This will load '<span class="code">header.php</span>' file if it exists.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Parameters:</h4>
					<div class="block">
						<pre>
							(string) $file
						</pre>
					</div>
					<p>
						Relative path to the file.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">
					<h4>Return:</h4>
					<div class="block">
						<p>
							(bool) TRUE if file exists, FALSE otherwise.
						</p>
					</div>
				</div>
				<div class="clear"></div>
				
			<h3 id="section5.3"><span class="code">$sill-&gt;route($route, $file)</span></h3>
				<p>
					Registers a route.
				</p>
				<p>
					This function should be used at the very beginning of the '<span class="code">functions.php</span>' file. Whenever a request for a file is made and the file does not exist in the '<span class="code">/site/assets/</span>' or '<span class="code">/site/modules/___/assets/</span>' (where ___ is the first segment in the URL) directories an attempt to match it to registered rewrite rules occurs. If a match has been found the request is directed to the specified file. If no match is found the request is directed to '<span class="code">index.php</span>' file.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$sill-&gt;route('@^admin/?$@', 'admin.php');
						</pre>
					</div>
					<p>
						This will redirect '<span class="code">[BASE_URL]/admin</span>' and '<span class="code">[BASE_URL]/admin/</span>' to '<span class="code">admin.php</span>' file.
					</p>
					<div class="block">
						<pre>
							$sill-&gt;route('@^user/([a-z0-9]+)$@i', 'user.php');
						</pre>
					</div>
					<p>
						This will redirect '<span class="code">[BASE_URL]/user/test</span>' and similar URLs to '<span class="code">user.php</span>' file. Notice the group in the rule, this will enable the group to be retrievable by '<span class="code">$sill-&gt;arguments()</span>' function.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Parameters:</h4>
					<div class="block">
						<pre>
							(string) $route
						</pre>
					</div>
					<p>
						Regular Expression against which the requested URLs are matched.
					</p>				
					<div class="block">
						<pre>
							(string) $file
						</pre>
					</div>
					<p>
						Relative path to the file the request will be directed to.
					</p>
				</div>
				<div class="clear"></div>

			<h3 id="section5.4"><span class="code">$sill-&gt;module($module)</span></h3>
				<p>
					Loads and initializes a module.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$sill->module('admin');
						</pre>
					</div>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Parameters:</h4>
					<div class="block">
						<pre>
							(string) $module
						</pre>
					</div>
					<p>
						Name of module's directory.
					</p>
					<div class="block">
						<pre>
							(mixed) [...] (optional)
						</pre>
					</div>
					<p>
						Additional arguments that will be passed to the module's constructor.
					</p>					
				</div>
				<div class="clear"></div>
				<div class="block white">
					<h4>Return:</h4>
					<div class="block">
						<p>
							(mixed) Instance of the module.
						</p>
					</div>
				</div>
				<div class="clear"></div>

			<h3 id="section5.5"><span class="code">$sill-&gt;URL($URL)</span></h3>
				<p>
					Gets the absolute URL.
				</p>
				<p>
					Useful for generating links.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							&lt;a href="&lt;?php echo $sill-&gt;get_URL('login'); ?&gt;"/&gt;Login&lt;/a&gt;
						</pre>
					</div>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Parameters:</h4>
					<div class="block">
						<pre>
							(string) (optional) $URL
						</pre>
					</div>
					<p>
						Relative URL to generate absolute URL from.
					</p>				
				</div>
				<div class="clear"></div>
				<div class="block white">
					<h4>Return:</h4>
					<div class="block">
						<p>
							(string) Absolute URL.
						</p>
					</div>
				</div>
				<div class="clear"></div>
				
			<h3 id="section5.6"><span class="code">$sill-&gt;arguments()</span></h3>
				<p>
					Gets arguments captured by the route.
				</p>
				<p>
					This function returns an array of matches. First is the complete matched URL, followed by every group matched in the route.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$sill-&gt;route('@^user/([a-z0-9]+)$@i', 'user.php');
						</pre>
					</div>
					<p>
						Let's assume that the request for '<span class="code">[BASE_URL]/user/test</span>' has been directed to '<span class="code">user.php</span>' file by the route above.
					</p>
					<div class="block">
						<pre>
							$arguments = $sill-&gt;arguments();
						</pre>
					</div>
					<p>
						Retrieve the URL arguments in '<span class="code">user.php</span>' file. '<span class="code">$arguments</span>' will be equal to.
					</p>
					<div class="block">
						<pre>
							array(<br/>
							&emsp;[0] =&gt; '/user/test',<br/>
							&emsp;[1] =&gt; 'test'<br/>
							);
						</pre>
					</div>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Return:</h4>
					<div class="block">
						<p>
							(array) Matches made against the rewrite rule.
						</p>
					</div>
				</div>
				<div class="clear"></div>
				
			<h3 id="section5.7"><span class="code">$sill-&gt;v(&$v)</span></h3>
				<p>
					Returns passed variable if it exists.
				</p>
				<p>	
					To use for objects or arrays, including multidimensional, pass attributes or keys as additional arguments.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$user_id = $sill-&gt;v($user, 0, 'ID');
						</pre>
					</div>
					<p>
						This will retrive $user[0]['ID'] value if it is set.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Parameters:</h4>
					<div class="block">
						<pre>
							(mixed) $v
						</pre>
					</div>
					<p>
						Variable to verify.
					</p>				
					<div class="block">
						<pre>
							(mixed) [...] (optional) Additional arguments specifying subsequent keys of the array or attributes of the object.
						</pre>
					</div>
					<p>
						Additional arguments specifying subsequent keys of the array.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Return:</h4>
					<div class="block">
						<p>
							(mixed) Passed variable if it exists, FALSE otherwise.
						</p>
					</div>
				</div>
				<div class="clear"></div>

			<h3 id="section5.8"><span class="code">$sill-&gt;PDO()</span></h3>
				<p>
					Gets the PDO object.
				</p>
				<p>	
					This function returns PDO object connected to <b>SiLL</b> database.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							$pdo = $sill-&gt;PDO();
						</pre>
					</div>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Return:</h4>
					<div class="block">
						<p>
							(PDO)
						</p>
					</div>
				</div>
				<div class="clear"></div>

			<h3 id="section5.9"><span class="code">$sill-&gt;version()</span></h3>
				<p>
					Gets <b>SiLL</b> version.
				</p>
				<div class="block white">
					<h4>Example:</h4>
					<div class="block">
						<pre>
							echo $sill-&gt;get_version();
						</pre>
					</div>
					<p>
						This will print out <b>SiLL</b> version.
					</p>
				</div>
				<div class="clear"></div>
				<div class="block white">	
					<h4>Return:</h4>
					<div class="block">
						<p>
							(string) <b>SiLL</b> version.
						</p>
					</div>
				</div>
				<div class="clear"></div>
				
	</body>
</html>
